<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

<jsp:directive.include file="/controleDeAcesso/autenticado.jsp" />

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>PersonalBiblio</title>
</head>
<body>
<f:view>
	<h2>Biblioteca Pessoal de <h:outputText value="#{usuarioMB.usuario.nome}"></h:outputText></h2>
	<jsp:include page="../../recursos/menu.jsp"></jsp:include>
	<h:form>
		<h:commandLink action="cadastrarLivro" value="(+) Adicionar um novo livro"></h:commandLink>
	</h:form>

	<h:dataTable border="1" value="#{usuarioMB.livros}" var="livro">
		<h:column id="column1">
			<f:facet name="header"><h:outputText value="Id"></h:outputText></f:facet>
			<h:outputText value="#{livro.id}"></h:outputText>
		</h:column>
		<h:column id="column2">
			<f:facet name="header"><h:outputText value="Título"></h:outputText></f:facet>
			<h:outputText value="#{livro.titulo}"></h:outputText>
		</h:column>
		<h:column id="column3">
			<f:facet name="header"><h:outputText value="Autor"></h:outputText></f:facet>
			<h:outputText value="#{livro.autor}"></h:outputText>
		</h:column>
		<h:column id="column4">
			<f:facet name="header"><h:outputText value="Editora"></h:outputText></f:facet>
			<h:outputText value="#{livro.editora}"></h:outputText>
		</h:column>
		<h:column id="column5">
			<f:facet name="header"><h:outputText value="Ano de Publicação"></h:outputText></f:facet>
			<h:outputText value="#{livro.anoPublicacao}"></h:outputText>
		</h:column>
		<h:column id="column6">
			<f:facet name="header"><h:outputText value="Nota"></h:outputText></f:facet>
			<h:outputText value="#{livro.nota}"></h:outputText>
		</h:column>
		<h:column id="column7">
			<f:facet name="header"><h:outputText value="Ações"></h:outputText></f:facet>
			<h:form>
				<h:commandLink value="Editar" action="#{usuarioMB.setAlterado}">
					<f:setPropertyActionListener value="#{livro.id}" target="#{usuarioMB.aAlterar.id}" />
				</h:commandLink>
				| <h:commandLink value="Remover" action="#{usuarioMB.removerLivro}">
					<f:setPropertyActionListener value="#{livro.id}" target="#{usuarioMB.idRemover}" />
				</h:commandLink>
			</h:form>
		</h:column>
	</h:dataTable>
	<br />
	<h:form>
		<h:commandLink action="#{usuarioMB.logout}"><h:outputText value="Efetuar logout"></h:outputText></h:commandLink>
	</h:form>
</f:view>
</body>
</html>